package com.zhiwang.planet.ui.my

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.zhiwang.planet.R
import com.zhiwang.planet.databinding.FragmentMobileBinding
import com.zhiwang.planet.di.component.DaggerUserComponent
import com.zhiwang.planet.di.module.AccountModule
import com.zhiwang.planet.di.module.AutoDisposeModule
import com.zhiwang.planet.mvvm.viewmodel.ItemDecorationViewModel
import com.zhiwang.planet.mvvm.viewmodel.my.MobileViewModel
import com.zhiwang.planet.ui.BaseFragment
import javax.inject.Inject

class MobileGameFragment(val b: Boolean) : BaseFragment() {


    @Inject
    lateinit var mobileViewModel: MobileViewModel

    @Inject
    lateinit var decorVm :ItemDecorationViewModel

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        DaggerUserComponent.builder()
                .appComponent(getAppComponent())
                .autoDisposeModule(AutoDisposeModule(requireActivity() as AppCompatActivity))
                .accountModule(AccountModule(requireActivity() as AppCompatActivity))
                .build()
                .inject(this)
        mobileViewModel.isMobile = b
    }


    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

        val root = inflater.inflate(R.layout.fragment_mobile, container, false)

        val binding = DataBindingUtil.bind<FragmentMobileBinding>(root)
        binding?.lifecycleOwner = viewLifecycleOwner
        binding?.viewModel = mobileViewModel
        binding?.decorVm = decorVm
        mobileViewModel.loadMobile()
        return root
    }


}